#include "feederonetwo.h"

Feederonetwo::Feederonetwo()
{
    atk = 100;
    hp = 400;
    time = int(1.6 * 1000 / 33);
    setMovie(":/picture/feederonetwo.gif");
}

void Feederonetwo::advance(int phase)
{
    if (!phase)
        return;
    //重绘
    update();
    //死亡
    if (hp <= 0)
        delete this;
    //CD结束
    else if (++counter >= time)
    {
        counter = 0;
        //检测到布布
        if (!collidingItems().isEmpty())
        {
            //发射奶瓶
            Feeder *feeder = new Feeder(atk);
            feeder->setX(x() + 32);
            feeder->setY(y());
            scene()->addItem(feeder);
            return;
        }
    }
}

bool Feederonetwo::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const
{
    Q_UNUSED(mode)
    return other->type() == Bubu::Type && qFuzzyCompare(other->y(), y());
}

